﻿using System;
namespace Producers.Calcdoc.Xtee.Riik.Ee.Producer.Calcdoc.Messages {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="HistoryRequest", Namespace="http://producers.calcdoc.xtee.riik.ee/producer/calcdoc", Target=typeof(HistoryRequest))]
    public class HistoryRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IHistoryRequest clazz;
        
        public HistoryRequestSerializer(IHistoryRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("request");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Request))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="request") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>GetHistory>request");
                }
                clazz.Request = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("request")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>GetHistory>request", Reader.LocalName);
            }
        }
    }
}
